home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Best of www.BestZips.com (Collector's Edition)
/
Best of WWW.BESTZIPS.COM Collector's Edition (JCSM Shareware) (JCS Marketing).ISO
/
prgtools
/
tn2.zip
/
FACT.T
< prev
next >
Wrap
Text File
|
1996-11-15
|
610b
|
40 lines
%
% "fact.t" computes the factorial of a number
% using recursion
%
% Sample program for the T Interpreter by:
%
% Stephen R. Schmitt
% 962 Depot Road
% Boxborough, MA 01719
%
var number : int
program
prompt "Enter an integer > 0:"
get number
put ""
put "N = ", number
put "N! = ", factorial( number )
end program
function factorial( n : int ) : int
assert n <= 12 % avoid numerical overflow
if n > 0 then
n := n * factorial( n - 1 )
else
n := 1
end if
return n
end function